package ano.printer;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author oldliu
 * @since 1.0
 */
@Service
public class Printer implements InitializingBean, BeanPostProcessor {
    ///品牌和价格
    @Value("惠普007炫彩系列")
    private String paizi;
    @Value("1500")
    private int price;
    @Resource(name = "caise")
    private Ink ink;
    @Autowired
    @Qualifier("a4")
    private Paper paper;
    public Printer(){

    }


    public void print(String str){
        System.out.println("使用价格是"+price+"元的"+paizi+"打印");
        System.out.println("使用"+ink.getColor()+"墨水");
        System.out.println(paper);
        paper.print(str);
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        if(price>1800){
            System.out.println(this.paizi+"有嗲贵");
        }else if(price>1000){
            System.out.println(this.paizi+"不便宜");
        }else{
            System.out.println(this.paizi+"便宜");
        }
    }
}
